# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>

_realname=goocanvas
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.0.0
pkgrel=4
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
pkgdesc="Canvas widget for GTK+ that uses the Cairo 2D library (mingw-w64)"
license=("LGPL 2")
url="https://www.gnome.org"
depends=("${MINGW_PACKAGE_PREFIX}-gtk3")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-python"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc"
             "${MINGW_PACKAGE_PREFIX}-gettext"
             "${MINGW_PACKAGE_PREFIX}-autotools"
             "patch")
options=('strip' '!debug' 'staticlibs')
source=(https://download.gnome.org/sources/${_realname}/${pkgver:0:3}/${_realname}-${pkgver}.tar.xz
             001-convert-python-path-to-unix.patch
             002-fix-introspection.patch
             003-Use-gettext-0.19.patch)
sha256sums=('670a7557fe185c2703a14a07506156eceb7cea3b4bf75076a573f34ac52b401a'
            '9740420cd1e2cf2362e5170ead007685686656e3764c905f7b0313b62ed41298'
            'b9e3815c1384e62b6745d52ee4ef69f2fe008bf7368e4ec7ab4809845650428d'
            '5b6628c39d048d391f1af40295d2d1029ec643ceae174e97f7bd045666b93ee8')

prepare() {
  cd ${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/001-convert-python-path-to-unix.patch
  patch -p1 -i ${srcdir}/002-fix-introspection.patch
  patch -p1 -i ${srcdir}/003-Use-gettext-0.19.patch
  autoreconf -fi
}

build() {
  cd "${srcdir}/${_realname}-${pkgver}"

  # an argument passed to glib-mkenums starts with a c++ comment
  export MSYS2_ARG_CONV_EXCL="/*;\n/*"
  export lt_cv_deplibs_check_method='pass_all'
  PYTHON=${MINGW_PREFIX}/bin/python \
  ./configure \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib \
    --enable-introspection=yes

  make
}

package() {
  cd "${srcdir}/${_realname}-${pkgver}"
  make DESTDIR=${pkgdir} install
}
